package net.zjitc.reflect.Annotation;

import java.lang.reflect.Method;

/**
 * Created by Administrator on 2017/11/6.
 */
public class AnmotationTest {
    public static void main(String[] args) throws ClassNotFoundException {
        //类对象
        Class clazz = Class.forName("net.zjitc.reflect.Annotation.MyAnnotation");
        //找所有的方法对象
        Method[] methods = clazz.getMethods();
        //通过遍历方法对象，获得有@ResultMapping的注解对象
        for (Method m :methods){
            ResultMapping annotation = m.getAnnotation(ResultMapping.class);
            //从注解对象中，取注解的参数
            if (annotation!= null){

               String name =  annotation.name();
               String url = annotation.url();
                System.out.println(name);
                System.out.println(url);
            }
        }
    }
}
